#ifndef BATTLEFIELD_H
#define BATTLEFIELD_H

#include "gamestate.h"
#include <vector>
#include "tile.h"
#include "Unit.h"
#include "Enemies/Enemy.h"

class Battlefield : public GameState
{
	public:
		Battlefield();
		virtual ~Battlefield() = default;

		void Update();
		void Draw();

		Battlefield(const Battlefield&);
		Battlefield& operator=(const Battlefield&);

		const int Num_Tiles = 20;
		static constexpr double Tile_Size = 29.99;



	protected:
	private:
		Tile** Tiles = new Tile*[Num_Tiles];
		std::vector<int> Cursor;
		std::vector<Unit*> Units;

		void GenerateRiver();
		void SetTile(std::vector<int> location, TileTypes type);
		bool IsTileType(std::vector<int> location, TileTypes type);
		bool IsValidPosition(std::vector<int> location);
		std::vector<std::vector<int>> GetAdjacentPositions(std::vector<int> Position);
		Unit* GetUnitAt(std::vector<int>);
		int Distance(std::vector<int> p1, std::vector<int> p2); //Manhattan distance
		bool UnitCanMoveTo(Unit*, std::vector<int> Position); //Checks if unit can move to position
		void EndTurn();
		void MoveEnemy(Enemy* e);
		int DistanceToClosestPlayer(std::vector<int>);

		enum class CursorModes{
			Free, UnitSelected, MainMenu
		};

		enum class MainMenuOptions{
			EndTurn = 0, QuitGame, Cancel, Size
		};

		enum class Turns{
			Player, Enemy
		};

		CursorModes CursorMode;
		MainMenuOptions MainMenuCursor;
		Turns CurrentTurn;

		Unit *SelectedUnit;
};

#endif // BATTLEFIELD_H
